﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Data;
using System.Windows.Media.Animation;

namespace Jive.CustomControls
{
    public partial class FauxKeyboardControl : UserControl
    {
        public event EventHandler<EventArgs> ShowFauxKeyboardCompleted;
        public event EventHandler<EventArgs> HideFauxKeyboardCompleted;
        public bool ShowFauxKeyboard
        {
            get { return (bool)GetValue(ShowFauxKeyboardProperty); }
            set
            {

                SetValue(ShowFauxKeyboardProperty, value);
            }
        }


        // Using a DependencyProperty as the backing store for ShowFauxKeyboard.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ShowFauxKeyboardProperty =
            DependencyProperty.Register("ShowFauxKeyboard", typeof(bool), typeof(FauxKeyboardControl), new PropertyMetadata(false, new PropertyChangedCallback(ShowFauxKeyboardProperty_Callback)));



        public FauxKeyboardControl()
        {
            InitializeComponent();
        }

        private static void ShowFauxKeyboardProperty_Callback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            FauxKeyboardControl control = dependencyObject as FauxKeyboardControl;
            if((bool)dependencyPropertyChangedEventArgs.NewValue==true)
            {
                control.FauxKeyboardGrid.Height = 415;
                if (control.ShowFauxKeyboardCompleted != null)
                    control.ShowFauxKeyboardCompleted(control, null);
            }
            else
            {
                control.FauxKeyboardGrid.Height = 0;
                if (control.HideFauxKeyboardCompleted != null)
                    control.HideFauxKeyboardCompleted(control, null);
            }
        }
       
    }
}
